<?php
session_start() ;
if(!isset($_SESSION["login"]) || $_SESSION["login"] == "")
{   
  header("Location: index.php?error=4") ;
}?>

<html>
<head>
<title>Administration</title>
 <link rel="stylesheet" type="text/css" href="style.css" >  
</head>

<body>
<?php require("menu.php");
require("fonctions.php");
$code=$_GET["error"];
$action=$_GET["action"];
?>
<p class="titre">Ajouter un nouvel manager</p>
<br></br>
<?php echo error_message($code);?>

<?php if($action=="new_man"){
$profil=$_GET["profil"];
	?>
<form action="controler.php?action=add_man&profil=<?php echo $profil;?>" method="post">
<table class="tab_dis" align="center">

<tr>
	<td class="th1">Nom</td><td class="th1"><input type="text" name="nom" ></td>
	</tr>
	<tr>
	<td class="th1">Pr&eacute;nom</td><td class="th1"><input type="text" name="prenom" ></td>
	</tr>
	<tr>
	<td class="th1">Adresse</td><td class="th1"><input type="text" name="adresse"  ></td>
	</tr>
	<tr>
	<td class="th1">Email</td><td class="th1"><input type="text" name="email" ></td>
	</tr>
	<tr>
	<td class="th1">Identifiant</td><td class="th1">
	<input type="text" name="login" value="<?php echo $row->groupe;?>" >
	</td>
	</tr>
	<tr>
	<td class="th1">Mot de passe</td><td class="th1">
	<input type="text" name="mdp" value="<?php echo $row->groupe;?>" >
	</td>
	</tr>
<tr>
	<td colspan=2 align=center></td><td></td>
</tr>
<tr>
	<td colspan=2 align=center><input type="submit" value="Enregistrer"></td>
</tr>
</table>
</form>

<?php }

if($action=="mod_dis_new"){
$id_dis = $_GET["id_dis"];

$sql="select * from distributeurs where id=$id_dis";
$res = mysql_query($sql);
$row = mysql_fetch_object($res);
$t_man = explode (",",getManagernameById(getIdManagerByDis($row->id)));
$val = "$t_man[0] $t_man[1]";
	?>
<form action="controler.php?action=mod_dis_new&id_dis=<?php echo $id_dis;?>" method="post">
<table class="tab_dis" align="center">

<tr>
	<td class="th1">Nom</td><td class="th1"><input type="text" name="nom" value="<?php echo $row->codesap;?>" disabled></td>
	</tr>
	<tr>
	<td class="th1">Pr&eacute;nom</td><td class="th1"><input type="text" name="prenom" value="<?php echo $row->nom;?>" ></td>
	</tr>
	<tr>
	<td class="th1">Adresse</td><td class="th1"><input type="text" name="adresse" value="<?php echo $row->groupe;?>" ></td>
	</tr>
	<tr>
	<td class="th1">Email</td><td class="th1"><input type="text" name="adresse" value="<?php echo $row->groupe;?>" ></td>
	</tr>
	<tr>
	<td class="th1">Identifiant</td><td class="th1">
	<input type="text" name="adresse" value="<?php echo $row->groupe;?>" >
	</td>
	<td class="th1">Mot de passe</td><td class="th1">
	<input type="text" name="mdp" value="<?php echo $row->groupe;?>" >
	</td>
	</tr>
	
<tr>
	<td colspan=2 align=center></td>
</tr>
<tr>
	<td colspan=2 align=center><input type="submit" value="Enregistrer"></td>
</tr>
</table>
</form>


<?php }?>

</body>

</html>
